import global, { Skill } from "../../global";

const {ccclass, property} = cc._decorator;

@ccclass
export default class TouchSkill extends cc.Component {

    skill:Skill = null;

    is_touch:boolean = false;   

    /**
     * 点击触发
     */
    onLoad(){
        this.node.on(cc.Node.EventType.TOUCH_START,this.touchStart,this);
        this.node.on(cc.Node.EventType.TOUCH_END,this.touchOver,this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL,this.touchOver,this);
    }

    /**
     * 按下
     */
    touchStart(){
        this.is_touch = true;
        this.scheduleOnce(()=>{
            this.show();
        },.5);
        
    }

    /**
     * 取消
     */
    touchOver(){
        this.is_touch = false;
        global.UI.skillDesc.close();;
    }

    /**
     * 是否
     */
    show(){
        if(this.is_touch){
            global.UI.skillDesc.openSkillDesc(this.skill);
        }
    }
}
